﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace ScrumTable.UI.View.Converter
{
    public class ConverterEnumVisibility : IValueConverter
    {
        public bool Invert { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string parameterString = parameter as string;
            var name = Enum.GetName(value.GetType(), value);
            bool isEqual = parameterString == name;
            isEqual = Invert ? !isEqual : isEqual;
            if (isEqual)
            {
                return Visibility.Visible;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


    public class ConverterEnumToBrush : IValueConverter
    {

        public Brush Value { get; set; }

        public ConverterEnumToBrush()
        {
            Value = Brushes.Black;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string parameterString = parameter as string;
            var name = Enum.GetName(value.GetType(), value);
            bool isEqual = parameterString == name;
            if (isEqual)
            {
                return Value;
            }
            return Brushes.Transparent;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

}
